package com.sc.pojo;

/**
 * 分页bean
 */

public class PageBean {
    private int currentpage;// 当前页面

    private int pagesize = 3;// 每页显示条数

    private int sumpage;// 总条数

    private int lastpage;// 尾页(总页数)

    public int getCurrentpage() {
        return currentpage;
    }

    public void setCurrentpage(int currentpage) {
        if (currentpage < 1) {// 当前页面小于1，页面数等于1；
            this.currentpage = 1;
        } else {
            if (currentpage > this.lastpage) {// 当前页面数大于尾页数，使当前页等于尾页数量
                this.currentpage = this.lastpage;
            } else {
                this.currentpage = currentpage;
            }
        }
    }

    public int getPagesize() {
        return pagesize;
    }

    public void setPagesize(int pagesize) {
        this.pagesize = pagesize;
    }

    public int getSumpage() {
        return sumpage;
    }

    public void setSumpage(int sumpage) {
        this.sumpage = sumpage;
        if (sumpage > 0) {// 通过总页数计算尾页数量
            lastpage = ((this.sumpage % pagesize == 0) ? (this.sumpage / pagesize) : (this.sumpage / pagesize + 1));
        }
    }

    public int getLastpage() {
        return lastpage;
    }

    public void setLastpage(int lastpage) {
        this.lastpage = lastpage;
    }

}